import { createAsyncThunk } from "@reduxjs/toolkit";
import Request from "http/Request";
import {PagingData, PagingResult} from "type/Page";
import {Report} from "type/entity/Report";

/** 请求报销单表分页数据 */
export const fetchReportPageData = createAsyncThunk(
    'report/fetchReportPageData',
    async (paging: PagingData) => {
        return await Request.get<PagingResult<Report>>("/record/report/page/" + paging.page + "/" + paging.pageSize);
    }
);

/** 添加报销单表数据 */
export const fetchAddReport = createAsyncThunk(
    'report/fetchAddReport',
    async (vo: Report) => {
       return await Request.put<number>("/record/report", vo);
    }
);

/** 更新报销单表数据 */
export const fetchUpdateReport = createAsyncThunk(
    'report/fetchUpdateReport',
    async (vo: Report) => {
        return await Request.post<number>("/record/report", vo);
    }
);

/** 删除报销单表数据 */
export const fetchDeleteReport = createAsyncThunk(
    'report/fetchDeleteReport',
    async (id: number) => {
        return await Request.delete<number>("/record/report" + id);
    }
);

